/*************************************************************
 * @file    audio_mgr.c          
 * @brief
 *
 *
 * @version   Version
 * @author    SealedGhost
 * @data
 *************************************************************/
	
	
	#include "audio_mgr.h"
	#include "gpio.h"
	
	
	static uint8_t AudioPermission  = 1;
	static uint8_t AudioState  = 0;
	
	
	inline void Audio_Enable()
	{
		 AudioPermission  = 1;
	}
	
	
	inline void Audio_Disable()
	{
		 AudioPermission  = 0;
		
		 if(AudioState > 0){
				 SpeakerOff(); 
			     //printf("Speaker off\n");
				 AudioState  = 0;
			}
	}
	
	
	
	inline void Audio_TurnOn(SpeakerOwner owner)
	{
		AudioState  |= (0x01 << owner);
		
		 if(AudioPermission){
				 SpeakerOn();
			     //printf("Speaker on\n");
			}
		 else{
//			 printf("Speaker on but permission denied\n");
             
		 }
	}
	
	
	
	inline void Audio_TurnOff(SpeakerOwner owner)
	{

			AudioState  &= ~(0x01 << owner);
		 if(AudioState == 0){
				 SpeakerOff();
			     //printf("Speaker off\n");
			}
	}
	
	
	